Skip to content

Conversation

@qexat
Copy link
Contributor

@qexat qexat commented Oct 30, 2025

A simple, lightweight library for ANSI styling

CHANGES:

Changes

  • Fmt has been rewritten from scratch to use my own library called rich-string. As such, a lot of tests have been dropped as they already exist upstream. The interface is mostly the same, besides the type itself and a few parameters that got renamed.
  • Fmt.print's ending parameter now takes a Fmt.t option instead of a string option.

Features

  • Ansi and Color now implement their own dedicated equality. No need to use the built-in polymorphic equality anymore.

Removed

  • Fmt's serialization feature is now dependent on rich-string. Since the latter does not provide it yet, serialization was dropped for now.
  • Fmt.show was also removed. On top of not being provided by rich-string and being the identity function, it was not all that useful.

@qexat
Copy link
Contributor Author

qexat commented Oct 30, 2025

A test is failing on some archs, probably still related to floating-point shenanigans (though I thought I had fixed it...), I'll try to see what is going on

@qexat qexat force-pushed the release-ansifmt-2.0.0 branch from 7082e3a to 583aa5e Compare October 30, 2025 11:11
@qexat
Copy link
Contributor Author

qexat commented Oct 30, 2025

Okay, I'm honestly out of ideas for fixing it on these three archs.

@jmid
Copy link
Member

jmid commented Oct 30, 2025

Hm. The test is comparing floating point values across widely different architectures IIUC:
https://github.com/qexat/ansifmt/blob/main/test/Test_ansi/Test_color.ml#L254-L273
Rounding etc may however differ.

How about just comparing the results up to some 'tolerance'? 🤔
https://www.geeksforgeeks.org/dsa/problem-in-comparing-floating-point-numbers-and-how-to-compare-them-correctly/

@qexat
Copy link
Contributor Author

qexat commented Oct 30, 2025

Hm. The test is comparing floating point values across widely different architectures IIUC: https://github.com/qexat/ansifmt/blob/main/test/Test_ansi/Test_color.ml#L254-L273 Rounding etc may however differ.

How about just comparing the results up to some 'tolerance'? 🤔 https://www.geeksforgeeks.org/dsa/problem-in-comparing-floating-point-numbers-and-how-to-compare-them-correctly/

I expected classify_float to work reliably on any architecture :( it annoys me to have to choose manually an epsilon, but I guess I'll have to do it

CHANGES:

## Changes

- `Fmt` has been rewritten from scratch to use my own library called `rich-string`. As such, a lot of tests have been dropped as they already exist upstream. The interface is mostly the same, besides the type itself and a few parameters that got renamed.
- `Fmt.print`'s `ending` parameter now takes a `Fmt.t option` instead of a `string option`.

## Features

- `Ansi` and `Color` now implement their own dedicated equality. No need to use the built-in polymorphic equality anymore.

## Removed

- `Fmt`'s serialization feature is now dependent on `rich-string`. Since the latter does not provide it yet, serialization was dropped for now.
- `Fmt.show` was also removed. On top of not being provided by `rich-string` and being the identity function, it was not all that useful.
@qexat qexat force-pushed the release-ansifmt-2.0.0 branch from 583aa5e to 4827b43 Compare October 30, 2025 11:49
@jmid
Copy link
Member

jmid commented Oct 30, 2025

I expect classification to work reliably. It is the subtraction result you are passing to it that may differ...
As a fun anecdote, on the 4.14 i386 native backend intermediate results may use extended precision,
except if you let-bind them! 😬
https://types.pl/@jmid/114797198537100006
ocaml/ocaml#8018

Copy link
Member

@jmid jmid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - all green now, LGTM!

Would you consider adding an x-maintenance-intent entry?
https://github.com/ocaml/opam-repository/blob/master/governance/policies/archiving.md

@qexat
Copy link
Contributor Author

qexat commented Oct 30, 2025

I will add it once I'm back home

@mseri
Copy link
Member

mseri commented Nov 3, 2025

If you want, we can add the intent manually here, without need to re-release. Then you can port it later to your main branch at your own convenience. What do you think? If you agree, what would be your preferred intent?

@qexat
Copy link
Contributor Author

qexat commented Nov 3, 2025

@mseri your suggestion is fine by me, we can do that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants